package com.party.web.web.controller.cosapi;

import com.party.core.service.cos.CosBizService;
import com.party.web.web.dto.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 腾讯云对象存储控制器
 * Created by Juliana
 *
 * @date 2017/12/08 0016
 * @time 9:43
 */

@Controller
@RequestMapping(value = "/cos/v4/api")
public class CosV4Controller {

    @Autowired
    CosBizService cosBizService;

    /**
     * 获取多次有效签名
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getAppSign")
    public AjaxResult getAppSign(Integer type){
        Map<String, Object> more = cosBizService.getCosSign("more", type);
        return AjaxResult.success(more);
    }


    /**
     * 获取单次有效签名
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getAppSignOnce")
    public AjaxResult getAppSignOnce(Integer type){
        Map<String, Object> more = cosBizService.getCosSign("once", type);
        return AjaxResult.success(more);
    }

    /**
     * 获取Cos对象存储配置
     * @param type: bucket类型 0: 图片, 1: 文件
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getConfig")
    public AjaxResult getConfig(Integer type){
        Map<String, Object> config = cosBizService.getConfig(type);
        return AjaxResult.success(config);
    }
}
